package halfQuestions;

import java.util.Arrays;
import java.util.Comparator;

public class Solution {
    public int halfQuestions(int[] questions) {
        // 贪心 选择元素相同的
        int[] map = new int[1001];
        int n = questions.length/2;
        for (int i = 0; i < questions.length; i++) {
            map[questions[i]]++;
        }
        int ans = 0,sum = 0;
        Arrays.sort(map);
        for (int i = map.length-1; i >=0 ; i--) {
            if(map[i]>0) {
                sum+=map[i];
                ans++;
            }
            if(sum>=n) {
                return ans;
            }
        }
        return ans;
    }
}
